
package com.platform.modules.mall.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.platform.modules.mall.entity.MallShopsEntity;
import com.platform.modules.mall.entity.MallShopsGoodsEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 店铺与商品关联关系Dao
 *
 * @author
 * @date 2019-07-04 09:46:59
 */
@Mapper
public interface MallShopsGoodsDao extends BaseMapper<MallShopsGoodsEntity> {

    /**
     * 获取商品可用店铺数量
     *
     * @param id goodsId
     * @return List
     */
    @Select("SELECT count(1) FROM MALL_SHOPS WHERE DELETE_STATUS=1 AND level = 2 and id in (\n" +
            "select B.ID from mall_shops_goods  A\n" +
            "left join mall_shops B on A.SHOPS_ID = B.id\n" +
            "where GOODS_ID = #{id}\n" +
            ") ")
    Integer getGoodsShopsCount(@Param("id") String id);

    /**
     * 查询所有列表
     *
     * @param params 查询参数
     * @return List
     */
    List<Map<String,Object>> getShopCardList(IPage page, @Param("params") Map<String, Object> params);

    /**
     * 查询所有列表
     *
     * @param params 查询参数
     * @return List
     */
    List<MallShopsGoodsEntity> queryAll(@Param("params") Map<String, Object> params);

    /**
     * 查询店铺所有商品分类
     *
     * @param shopsId
     * @return List
     */
    List<MallShopsGoodsEntity> selectMallShopsGoodsCategory(@Param("params") Map<String, Object> params);

    /**
     * 自定义分页查询
     *
     * @param page   分页参数
     * @param params 查询参数
     * @return List
     */
    List<MallShopsGoodsEntity> selectMallShopsGoodsPage(IPage page, @Param("params") Map<String, Object> params);

    List<MallShopsEntity> selectShopsByGoodsId(@Param("goodsId") String goodsId);
}
